package com.shoponline.test;

import java.util.ArrayList;

import org.hibernate.Session;

import com.shoponline.dao.DAOFactory;
import com.shoponline.dao.UserDAOTest;
import com.shoponline.po.User;
import com.shoponline.util.Generator;
import com.shoponline.util.HibernateUtil;
import com.shoponline.util.TypeConversionTools;

public class HelloWorld {

	public static void main(String[] args){
		
		HelloWorld helloWorld = new HelloWorld();
		helloWorld.excute();
		
	}
	
	public void hello(){
		
		Session session = HibernateUtil.getSession();
		User user = new User();
		user.setUserid("200910414212");
		user.setUsername("yunl.zheng");
		user.setEmail("yunl.zheng@gmail.com");
		user.setPassword("zhyl");
		user.setTelephone("13666157026");
		user.setRegisttime(TypeConversionTools.String2timestamp("2009-12-31 12:22:22"));
		session.beginTransaction();
		session.save(user);//持久化noteBook
		session.getTransaction().commit();
		session.close();
		
	}
	
	public void excute(){
		
		DAOFactory factory = DAOFactory.instance(DAOFactory.HIBERNATE);
		UserDAOTest userDao = factory.getUserDAO();
		User user = userDao.checkLogin("627899835@gmail.com", "zhyl");
		if(user!=null){
			
			System.out.println(user.getEmail()+"："+user.getPassword());
			
		}
	}
	
}
